﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Xml.Serialization;
using System.ComponentModel;
using System.IO;

namespace Imdb
{
    [Serializable]
    [XmlInclude(typeof(Movie))]
    [XmlInclude(typeof(Person))]
    public class Movie
    {

        public bool AlreadyDownloaded { get; set; }
        public string Id { get; set; }
                
        public string Title { get; set; }
        public string Description { get; set; }
        public DateTime? ReleaseDate { get; set; }   
        
        public List<Person> Directors { get; set; }
        public List<Person> Cast { get; set; }
        public List<Person> Producers { get; set; }
        public List<Person> Writers { get; set; }
        public List<Person> MusicBy { get; set; }
        public List<Person> CastingBy { get; set; }
        public List<Person> SpecialEffects { get; set; }
        public List<Person> Stunts { get; set; }
        public List<Person> CostumeDesignBy { get; set; }

        public List<string> ProductionCompanies { get; set; }
        public List<string> Distributors { get; set; }
        public List<string> SpecialEffectsCompanies { get; set; }
        public List<string> OtherCompanies { get; set; }
        
        public List<string> Genres { get; set; }
        public List<string> Languages { get; set; }
        public string Rated { get; set; }

        public int Year { get; set; }
        public double UserRating { get; set; }
        public double Votes { get; set; }

        [System.Xml.Serialization.XmlIgnore]
        public Image Poster { get; set; }

        [XmlElementAttribute("ThePicture")]
        public byte[] PictureByteArray
        {
            get
            {
                if (Poster != null)
                {
                    TypeConverter BitmapConverter =
                         TypeDescriptor.GetConverter(Poster.GetType());
                    return (byte[])
                         BitmapConverter.ConvertTo(Poster, typeof(byte[]));
                }
                else
                    return null;
            }

            set
            {
                if (value != null)
                    Poster = new Bitmap(new MemoryStream(value));
                else
                    Poster = null;
            }
        }

        public string PosterUrl { get; set; }
        public bool HasTrailer { get; set; }
        public string TrailerUrl { get; set; }
        
        public List<string> KnownTitles { get; set; }
        public List<Movie> RecommendedFilms { get; set; }

        public int Runtime { get; set; }
        public string Tagline { get; set; }
             
        public bool IsTvSerie { get; set; }
        public List<int> Seasons { get; set; }
        
        [System.Xml.Serialization.XmlIgnore]
        public object Tag { get; set; }        

    }
}
